#include <iomanip>
#include <iostream>
#include <stdlib.h>
#include <string.h>

#include "Random.h"
#include "Player.h"



using namespace std;


/**
 * Constructor
 * All members are set to 0.
 */
Player::Player()
{
	setAttributes(0, 0, 0, 0, 0);
	m_class = NULL;
}


/**
 * Destructor
 */
Player::~Player()
{
	if (m_class != NULL)
		delete m_class;
}


/**
 * The Player is resting and HP and MP are restored
 * @param void
 * @return void
 */
void Player::Rest()
{
	system("cls");
	cout << "   .)" << endl;
	cout << "  .(" << endl;
	cout << "   /%/\\" << endl;
	cout << "  (%(%))" << endl;
	cout << " .-'..`-." << endl;
	cout << " `-'.'`-'"  << endl << endl;
	cout << endl << "You are resting around your campfire." << endl << endl;
	m_iHP = m_iMaxHP;
	m_iMP = m_iMaxMP;
	system("pause");
}


/**
 * Increase Level of the Player
 * @param void
 * @return void
 */
void Player::levelUp()
{
	++m_iLevel;
}


/**
 * Set the Initial equipment of the Player
 * @param std::vector<Item*> items - list of items to create in the Player's equipment
 * @return void
 */
void Player::setInitialEquipment(std::vector<Item*> items)
{
	for (unsigned int i = 0; i < m_class->m_InitEqpt.size(); ++i)
	{
		int itemID = 0;

		itemID = addEquipment(m_class->m_InitEqpt[i].c_str(), items);
		addInBackpack(itemID);
	}
}


/**
 * Print the Players information
 * @param void
 * @return void
 */
void Player::print()
{
	system("cls");
	cout << endl << endl;
	cout << "   ,-----------------------------------------------------------,==." << endl;
	cout << "  /                                                           /__  \\" << endl;
	cout << " |                                                           |(_\\ /" << endl;
	cout << " |                                                           \\-`-'" << endl;
	cout << " |                                                           /" << endl;
	cout << " |" << setw(60) << setfill('_') << "|" << endl;
	cout << " | Name: " << m_strName << endl;
	cout << " | Profession: " << m_class->getName() << endl;
	cout << " | Rank: " << m_iLevel << endl;
	cout << " | Experience: " << m_iXP << "/" << m_iMaxXP << endl;
	cout << " |" << endl;
	cout << " |" << setw(60) << setfill('_') << "|" << endl;
	cout << " | Health Points: " << m_iHP << "/" << m_iMaxHP <<  endl;
	cout << " | Magic Points: " << m_iMP << "/" << m_iMaxMP <<  endl;
	cout << " |" << endl;
	cout << " |" << setw(60) << setfill('_') << "|" << endl;
	printBaseChar();
	printCombatFactor();
	printFurtivity();
	printEquipment();
	cout << " |                                                           |" << endl;
	cout << " |                                                           {____"<< endl;
	cout << " |                                                           |__( \\" << endl;
	cout << " \\                                                           \\    /" << endl;
	cout << "  `-----------------------------------------------------------`=='" << endl;
	cout << endl;
	system("pause");
	system("cls");
}


/**
 * Print the Players specific information
 * @param void
 * @return void
 */
void Player::printBaseChar()
{
	cout << " | BASE CHARACTERISTICS" << endl; 
	cout << " |" << setw(60) << setfill('_') << "|" << endl;
	cout << setfill(' ') << " | Strength:\t\t" << setw(2) << m_iStrength << endl;
	cout << setfill(' ') << " | Reflexes:\t\t" << setw(2) << m_iReflexes << endl;
	cout << setfill(' ') << " | Intelligence:\t" << setw(2) << m_iIntelligence << endl;
	cout << setfill(' ') << " | Psychic:\t\t" << setw(2) << m_iPsychic << endl;
	cout << setfill(' ') << " | Charisma:\t\t" << setw(2) << m_iCharisma << endl;
	cout << " |" << endl;
	cout << " |" << setw(60) << setfill('_') << "|" << endl;
}


